const { DataTypes, Sequelize } = require("sequelize");
const sequelize = require("./sequelizeBaseConfig.js");

const Message = sequelize.define(
  "Message",
  {
    id: {
      type: DataTypes.BIGINT,
      comment: "ID",
      autoIncrement: true, //自增
      primaryKey: true, //主键
    },
    created_at: {
      type: DataTypes.DATE,
      comment: "创建时间",
      defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), //如果没有设置该字段的值则使用默认
    },
    updated_at: {
      type: DataTypes.DATE,
      comment: "更新时间",
      defaultValue: Sequelize.literal(
        "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
      ),
    },
    nickname: {
      type: DataTypes.STRING,
      comment: "用户名",
      allowNull: true,
    },
    avatar: {
      type: DataTypes.STRING,
      comment: "头像",
      allowNull: true,
    },
    content: {
      type: DataTypes.STRING,
      comment: "留言",
      allowNull: true,
    },
    ip_address: {
      type: DataTypes.STRING,
      comment: "id地址",
      allowNull: true,
    },
    ip_source: {
      type: DataTypes.STRING,
      comment: "id资源",
      allowNull: true,
    },
    is_review: {
      type: DataTypes.TINYINT,
      comment: "是否审核(0.否 1.是)",
      allowNull: true,
    },
    speed: {
      type: DataTypes.TINYINT,
      comment: "弹幕速度",
      allowNull: true,
    },
  },
  { tableName: "message", timestamps: false }
);

module.exports = {
  Message,
};
